<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Login Page</title>
    <!-- 样 式 文 件 -->
    <link rel="stylesheet" href="__PLU__/pear/css/pear.css"/>
    <link rel="stylesheet" href="__ST__/admin/css/other/login.css"/>
</head>
<!-- 代 码 结 构 -->
<body background="__ST__/admin/images/background2.svg" style="background-size: cover;">
<form class="layui-form" action="/admin/login/dologin">
    <div class="layui-form-item">
        <img class="logo" src="__IMG__/logo.png"/>
    </div>
    <div class="layui-form-item">
        <input type="text" placeholder="账 户 : " name="username" hover class="layui-input"/>
    </div>
    <div class="layui-form-item">
        <input type="password" placeholder="密 码 : " name="password" hover class="layui-input"/>
    </div>
    <div class="layui-form-item">
        <input type="text" placeholder="验证码 : " name="verify" hover class="code layui-input layui-input-inline"/>
        <img src="{:captcha_src()}" alt="captcha" class="codeImage"/>
    </div>
    <div class="layui-form-item">
        <input type="checkbox" name="" title="记住密码" lay-skin="primary" checked>
    </div>
    <div class="layui-form-item">
        <button type="button" class="pear-btn pear-btn-success login" lay-submit lay-filter="login">
            登 入
        </button>
    </div>
</form>
<!-- 资 源 引 入 -->
<script src="__LAYUI__/layui.js"></script>
<script src="__PLU__/pear/pear.js"></script>
<script>
    layui.use(['jquery', 'form', 'button', 'popup'], function () {
        var $ = layui.jquery;
        var form = layui.form;
        var button = layui.button;
        var popup = layui.popup;
        $('.codeImage').on('click', function () {
            var ts = Date.parse(new Date()) / 1000;
            $(this).attr("src", "/captcha?id=" + ts);
        });
        // 登 录 提 交
        form.on('submit(login)', function (data) {
            var dom = button.load({elem: '.login'});
            $.post(data.form.action, data.field, function (info) {
                if (info.code) {
                    popup.success("登录成功", function () {
                        window.location.href='/admin';
                    });
                } else {
                    popup.failure("登录失败！<br>Error：" + info.msg);
                    $('.codeImage').trigger('click');
                    dom.stop();
                }

            }, 'json');
            return false;

        });
    })
</script>
</body>
</html>
